package milu.dbxml.request;

import milu.dbxml.DbXmlContext;
import milu.dbxml.receipt.Recipient;

import org.apache.log4j.Logger;

import com.sleepycat.dbxml.XmlDocumentConfig;
import com.sleepycat.dbxml.XmlException;
import com.sleepycat.dbxml.XmlQueryContext;
import com.sleepycat.dbxml.XmlQueryExpression;
import com.sleepycat.dbxml.XmlResults;

/**
 * Proaktiver Zugriff erlaubt den Aufruf von {@link XmlResults#size()}.
 * 
 * @author MiLu
 */
public abstract class EagerQuery extends TransactionalQuery {
	final static Logger log = Logger.getLogger(TransactionalQuery.class);

	public EagerQuery(DbXmlContext dbxml, XmlQueryExpression xqe,
			Recipient recipient) {
		super(dbxml, xqe, recipient);
	}

	@Override public void perform() throws XmlException {
		XmlQueryContext xqc = dbxml.getQueryContext();
		log.info("XQuery geht los");
		this.results = this.xqe.execute(getTransaction(), xqc,
				getXmlDocumentConfig());
	}

	protected XmlDocumentConfig getXmlDocumentConfig() {
		return new XmlDocumentConfig();
	}
}
